{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['state' 'value' 'year']\n",
      "[dtype('bool') dtype('float64') dtype('<M8[ns]')]\n",
      "['state']\n",
      "['True', '0.8', '1985-01-01 00:00:00']\n",
      "['False', '0.3', '1986-01-01 00:00:00']\n",
      "['True', '0.75', '1987-01-01 00:00:00']\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from datetime import datetime\n",
    "data = pd.DataFrame(\n",
    "{\n",
    "    'state':[True, False, True],\n",
    "    'value':[0.8, 0.3, 0.75],\n",
    "    'year':[datetime(1985, 1, 1),datetime(1986, 1, 1),datetime(1987, 1, 1)]\n",
    "}\n",
    ")\n",
    "# 获得信息\n",
    "# ----\n",
    "# 获得列名\n",
    "print(data.columns.values)\n",
    "# 获得列类型\n",
    "print(data.dtypes.values)\n",
    "# 获得为bool类型的列名\n",
    "print([name for name, dtype in zip(data.columns.values, data.dtypes.values) if str(dtype) == 'bool'])\n",
    "# 或的\n",
    "for line in data.values:\n",
    "    print([str(e) for e in line])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
